﻿using System;
using System.Runtime.Serialization;

namespace OpenWaves.EPiServer.BrightcoveVideoCloudProperty
{
    [DataContract]
    public class Video
    {
        [DataMember(Name = "name")]
        public string Name { get; set; }

        [DataMember(Name = "thumbnailUrl")]
        public string ThumbnailUrl { get; set; }

        [DataMember(Name = "id")]
        public long Id { get; set; }

        [DataMember(Name = "shortDescription")]
        public string ShortDescription { get; set; }

        [DataMember(Name = "publishedDate")]
        public string PublishedDate { get; set; }

        [DataMember]
        public DateTime Date
        {
            get
            {
                if (string.IsNullOrWhiteSpace(this.PublishedDate))
                    return DateTime.Now;

                return DataTimeExtensions.DateFromUnix(this.PublishedDate);
            }
            set
            {
                this.PublishedDate = DataTimeExtensions.DateToUnix(value);
            }
        }
    }
}